<title>用户组权限</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>问答管理</cite></a>
    <a><cite>用户管理</cite></a>
    <a><cite>用户组权限</cite></a>
  </div>
</div>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          
    <div class="layui-card-body">

          <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
              <li {if $type eq 'default'}class="layui-this"{/if} lay-href="wendasns/group/index?type=default">会员组</li>
              <li {if $type eq 'admin'}class="layui-this"{/if} lay-href="wendasns/group/index?type=admin">管理组</li>
            </ul>
            <div class="layui-tab-content">
              <div class="layui-tab-item layui-show">

			      <div style="padding-bottom: 10px;">
			        <button class="layui-btn J_groupAdd"><i class="layui-icon layui-icon-add-circle"></i> 添加</button>
			        <a href="wendasns/group/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i> 删除</a>
			      </div>
			      
			      <table id="J_table_list" lay-filter="J_table_list"></table>
      
              </div>
            </div>
          </div>
      
        </div>
	  </div>
    </div>
  </div>
</div>

<script type="text/html" id="J_table_tool">
  <a lay-href="wendasns/group/edit?id={{d.id}}" class="layui-btn layui-btn-normal layui-btn-xs"><i class="layui-icon layui-icon-edit"></i> 编辑</a>
  <a href="wendasns/group/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确实要删除吗？"><i class="layui-icon layui-icon-delete"></i> 删除</a>
</script>

<script>
;!function(){
  var $ = layui.$
  ,admin = layui.admin
  ,table = layui.table;
  
  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('wendasns/group/list',['type'=>$type])}'
  ,cols: [[
      {type: 'checkbox'}
      ,{field:'id',title:'ID',align:'center',width:80}
      ,{field:'name',title:'组别名称',minWidth:200}
      ,{title:'操作',width:180,align:'center',toolbar:'#J_table_tool'}
  ]]
  ,height: 'auto'
  ,page: true
  ,limit: 20
  ,text: {
    none: '暂无数据！'
  }
});

	$('.J_groupAdd').click(function(){
      layer.prompt({title: '请输入用户组名称', formType: 0}, function(value, index){
      
      	admin.req({
			url: '{:url('wendasns/group/add')}'
			,type: 'post'
			,data: {name:value,type:'{$type}'}
			,dataType: 'json'
			,done: function(res){
				layer.msg(res.msg, {time:1500}, function(){
					admin.events.refresh();
				});
			}
      	});
        
      });
      
	});
	

      
}();
</script>

